package com.captain.leetcode.二分查找;

import java.util.Arrays;

/**
 * @author captain
 * @Des
 * @Date 2021/8/7 9:57
 */
public class 搜索旋转排序数组II81 {

    public boolean search(int[] nums, int target) {
        // 1 , 2, 3 ,4 ,5 ,6 ,
        Arrays.sort(nums);
        int left = 0, right = nums.length - 1;
        while (left <= right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] == target) return true;
            else if (target > nums[mid]) left = mid + 1;
            else if (target < nums[mid]) right = right - 1;
        }
        return false;
    }
}
